<template>
  <view class="deep">
    <!-- 头部 -->
    <view class="scroll_header"></view>
    <scroll-view scroll-y="true" :style="{height: scrollHeight}" :scroll-top="scrollTop" @scroll="scroll"
      @scrolltolower="scrolltolower" refresher-enabled="true" :refresher-triggered="triggered"
      :refresher-threshold="100" @refresherpulling="onPulling" @refresherrefresh="onRefresh"
      @refresherrestore="onRestore">
      <view class="mt-5" v-if="u_loadmore">
        <u-loadmore status="loading" icon-type="circle" />
      </view>
      <view class="" v-else>
        <view class="order_header">
          <view class="m-2 d-flex bg-white p-2 rounded-20">
            <view class="flex-1" v-for="(item,index) in goodsList" :key="index" @click="tabgoods(index+1)">
              <view class="text-center">
                <image :src="item.img" mode="widthFix" class="goods_im"></image>
              </view>
              <view class="font text-center">{{item.name}}</view>
            </view>
          </view>
        </view>
        <view v-if="saleList.length<=0" class="d-flex flex-column w-100 h-70 a-center j-center">
          <image src="../../static/images/home/icon_no_data.png" mode="" class="icon_no_data"></image>
          <view class="">暂无商品</view>
        </view>
        <view v-else class="goods_card bg-white m-2 p-3 rounded-20" v-for="(item,index) in saleList" :key="index">
          <view class="goods_card_head d-flex" @click="goodsDetail(item)">
            <view class="goods_card_head_left position-relative ">
              <view v-if="item.has_product=='yes'" class="text-white goods_logo">多货品</view>
              <image class="img_url" :src="item.img.url?item.img.url:defaltImage" mode="aspectFit"></image>
              <view class="position-absolute top-0 left-0 z-222" v-if="item.goods_video_url">
                <image src="../../static/images/goods/video.png" mode="" class="video_img"></image>
              </view>
            </view>
            <view class="goods_card_head_right pl-3">
              <view class="d-flex">
                <view class="ellipsis pro_name">
                  <image v-if="item.is_hot" src="../../static/images/goods/icon_goods_hot.png" class="mr" mode="">
                  </image>
                  <image v-if="item.is_new" src="../../static/images/goods/icon_goods_new.png" class="mr" mode="">
                  </image>
                  <image v-if="item.is_best" src="../../static/images/goods/icon_goods_best.png" class="mr" mode="">
                  </image>
                  <image v-if="item.is_promote" src="../../static/images/goods/promotion.png" class="mr" mode="">
                  </image>
                  {{item.name}}
                </view>
              </view>
              <view class="text-light-muted font-md my pt-2">
                <text class="mr-3">库存：{{item.stock}}</text>
                <text>销量：{{item.sales_volume}}</text>
              </view>
              <view class="mt-1 pt">
                <text class="text-danger mr-2 font-35">{{item.shop_price}}</text><text
                  class="font-md text-light-muted tex line-through">{{item.market_price}}</text>
              </view>
            </view>
          </view>
          <view class="mt-2 font d-flex j-end" v-if="item.is_on_sale==1&&item.stock!=0">
            <view class="goods_card_content_footer" v-for="(goodsItem,goodsIndex) in sale_items" :key="goodsIndex"
              @click="goodsOpen(goodsItem,item)">
              <view>{{goodsItem.title}}</view>
            </view>
          </view>
          <view class="mt-2 font d-flex j-end" v-else-if="item.stock==0">
            <view class="goods_card_content_footer" v-for="(storeItem,storeIndex) in store_items" :key="storeIndex"
              @click="goods_store(storeItem,item)">
              <view>{{storeItem.title}}</view>
            </view>
          </view>
          <view class="mt-2 font d-flex j-end" v-else>
            <view class="goods_card_content_footer" v-for="(underItem,underIndex) in under_items" :key="underIndex"
              @click="goods_under(underItem,item)">
              <view>{{underItem.title}}</view>
            </view>
          </view>
        </view>
        <view class="pb-2" v-if="!saleList.length<=0">
          <view class="" v-if="saleList.length==total" @click="loadmores">
            <u-loadmore status="nomore" icon-type="circle" />
          </view>
          <view class="" v-else>
            <u-loadmore status="loading" icon-type="circle" />
          </view>
        </view>
      </view>
    </scroll-view>
    <!-- 改价 -->
    <u-popup @open="open_focus" @close="close_focus" v-model="mouseShow" negative-top="200" width="90%" mode="center"
      border-radius="14" :closeable="true" close-icon="close" close-icon-pos="top-right" close-icon-size="40">
      <view class="py-2 border-bottom">
        <view class="font-md d-flex j-center a-center">快速改价</view>
      </view>
      <view class="d-flex font-md">
        <view class="goods_card_head_left position-relative m-2">
          <view v-if="items.has_product=='yes'" class="text-white goods_logo">多货品</view>
          <image class="popupImg" :src="items.img.url?items.img.url:defaltImage" mode=""></image>
        </view>
        <view class="p-3">
          <view class="font-md">现&nbsp;&nbsp;&nbsp;价:&nbsp;<text
              class="text-danger ml-1 font-md">{{items.shop_price}}</text></view>
          <view class="d-flex pt-3">
            <view class="font-md nowrap">调整至:</view>
            <view class="d-flex bg-light-secondary py-1 rounded-10 font-md ml-2"><input type="digit" focus
                :focus="firstFocus" @focus="change_input" class="text-center" placeholder-class="text-center"
                v-model="changePrice" @input="changeInput" /></view>
          </view>
        </view>
      </view>
      <button type="warn" class="pupup" @click="ConfirmPrice">确认</button>
      <view class="text-center text-primary py-3" @click="expert">高级改价</view>
    </u-popup>
    <!--下架 -->
    <u-modal v-model="downShow" title="下架提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="downFarme">
      <view class="py-3">
        <view class="text-center">你确定要把该商品下架吗?</view>
      </view>
    </u-modal>
    <!-- 改库存 -->
    <u-popup @open="open_store" @close="close_store" v-model="store_Show" negative-top="200" width="90%" mode="center"
      border-radius="14" :closeable="true" close-icon="close" close-icon-pos="top-right" close-icon-size="40">
      <view class="py-2 border-bottom">
        <view class="font-lg d-flex j-center a-center">修改库存</view>
      </view>
      <view class="py-3">
        <view class="d-flex j-center">
          <view class="d-flex flex-column ml-5 py-3 pl-5">
            <view class="">当前库存:<text class="text-danger ml-1">0</text></view>
            <view class="d-flex pt-3 a-center">
              <view>调整至:&nbsp;</view>
              <view class="ml-1 d-flex bg-light-secondary rounded-10 py-1"><input type="digit" class="text-center"
                  @focus="store_input" focus :focus="firstFocus" v-model="modify_stock" @input="modify" /></view>
            </view>
          </view>
        </view>
        <button type="warn" class="pupup" @click="stock">库存</button>
      </view>
    </u-popup>
    <!-- 智能权重 -->
    <u-popup v-model="weightShow" width="90%" mode="center" border-radius="14" :closeable="true" close-icon="close"
      close-icon-pos="top-right" close-icon-size="40">
      <view class="py-2 border-bottom">
        <view class="font-lg d-flex j-center a-center">智能权重</view>
      </view>
      <view class="bg-light-secondary pb-2">
        <view class="border-bottom  d-flex pl-2">
          <view class="border-right span-10 py-1">商品购买数量</view>
          <view class="text-center span-10 py-1">0</view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">商品退换数量</view>
          <view class="text-center span-10 py-1">{{weightList.return_number!==false?'0':weightList.return_number}}
          </view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">购买此商品的会员数量</view>
          <view class="text-center span-10 py-1">{{weightList.user_number!==false?'0':weightList.user_number}}</view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">对此商品评价数量</view>
          <view class="text-center span-10 py-1">
            {{weightList.goods_comment_number!==false?'0':weightList.goods_comment_number}}
          </view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">对此商品商家评价数量</view>
          <view class="text-center span-10 py-1">
            {{weightList.merchants_comment_number!==false?'0':weightList.merchants_comment_number}}
          </view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">会员关注此商品数量</view>
          <view class="text-center span-10 py-1">
            {{weightList.user_attention_number!==false?'0':weightList.user_attention_number}}
          </view>
        </view>
        <view class="border-bottom d-flex pl-2">
          <view class="border-right span-10 py-1">人工干预值</view>
          <view class="text-center span-10 py-1"><input value="interfere" type="text" v-model="interfere"
              @input="interfereInput" @confirm="weight" /></view>
        </view>
      </view>
    </u-popup>
    <!-- 更多 -->
    <s-popup custom-class="demo-popup" position="bottom" v-model="moreShow">
      <!-- 内容 -->
      <view class="d-flex j-center a-center">
        <view class="content span-19 rounded-20 mx-2">
          <!-- <view class="py-3 border-bottom text-center" @click="share">分享</view> -->
          <view class="py-3 border-bottom text-center" @click="goods_recycle">移至回收站</view>
          <view class="py-3 border-bottom d-flex j-center a-center" @click="is_new">
            <image class="goods_icon" v-if="items.is_new"
              :src="items.is_new?'../../static/images/goods/icon_goods_new.png':''" mode="widthFix"></image>
            <view class="ml-1">{{items.is_new?"取消":"设置"}}新品</view>
          </view>
          <view class="py-3 border-bottom d-flex j-center a-center" @click="is_hot">
            <image class="goods_icon" v-if="items.is_hot"
              :src="items.is_hot?'../../static/images/goods/icon_goods_hot.png':''" mode="widthFix"></image>
            <view class="ml-1">{{items.is_hot?"取消":"设置"}}热销</view>
          </view>
          <view class="py-3 border-bottom d-flex j-center a-center" @click="is_best">
            <image class="goods_icon" v-if="items.is_best"
              :src="items.is_best?'../../static/images/goods/icon_goods_best.png':''" mode="widthFix"></image>
            <view class="ml-1">{{items.is_best?"取消":"设置"}}精品</view>
          </view>
        </view>
      </view>
      <view class="d-flex j-center a-center span-19 py-3 bg-white mx-2 my-2 rounded-25 " @click="cancelMore">
        取消
      </view>
    </s-popup>
    <!-- 商品移至回收站 -->
    <u-modal v-model="delShow" title="提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="confirm_delShow">
      <view class="py-3">
        <view class="text-center">你确定要将商品移至回收站吗？</view>
      </view>
    </u-modal>
    <!-- 分享 -->
    <s-popup custom-class="demo-popup" position="bottom" v-model="shareShow">
      <!-- 内容 -->
      <view class="m-2 bg-white rounded-20 icon_share py-2">
        <view class="border-bottom d-flex ml-4 py-4">
          <view class="text-center">
            <image src="../../static/images/goods/icon_share_wechat_timeline.png" mode=""></image>
            <view class="">朋友圈</view>
          </view>
          <view class="text-center ml-3">
            <image src="../../static/images/goods/icon_share_wechat.png" mode=""></image>
            <view class="">微信</view>
          </view>
          <view class="text-center ml-3">
            <image src="../../static/images/goods/icon_share_qq.png" mode=""></image>
            <view class="">QQ</view>
          </view>
        </view>
        <view class="d-flex ml-4 py-4">
          <view class="text-center">
            <image src="../../static/images/goods/icon_share_clipboard.png" mode=""></image>
            <view class="">复制链接</view>
          </view>
          <view class="text-center ml-3">
            <image src="../../static/images/goods/icon_share_qrcode.png" mode=""></image>
            <view class="">二维码</view>
          </view>
        </view>
      </view>
      <view class="d-flex j-center a-center span-19 py-3 bg-white mx-2 my-1 rounded-25" @click="cancelShare">
        取消
      </view>
    </s-popup>
    <!-- 新品 -->
    <u-modal v-model="is_newShow" title="提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="confirm_is_new">
      <view class="py-3">
        <view class="text-center">你确定要把选中的商品{{items.is_new?'取消':'设置'}}新品吗?</view>
      </view>
    </u-modal>
    <!-- 热销 -->
    <u-modal v-model="is_hotShow" title="提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="confirm_is_hotShow">
      <view class="py-3">
        <view class="text-center">你确定要把选中的商品{{items.is_hot?'取消':'设置'}}热销吗?</view>
      </view>
    </u-modal>
    <!-- 精品 -->
    <u-modal v-model="is_bestShow" title="提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="confirm_is_bestShow">
      <view class="py-3">
        <view class="text-center">你确定要把选中的商品{{items.is_best?'取消':'设置'}}精品吗?</view>
      </view>
    </u-modal>
    <!-- 上架 -->
    <u-modal v-model="getupShow" title="上架提示" :show-title="false" show-confirm-button show-cancel-button
      @confirm="getupFarme">
      <view class="py-3">
        <view class="text-center">你确定要把该商品上架吗?</view>
      </view>
    </u-modal>
  </view>
</template>

<script>
  import sPopup from '@/components/s-popup/index.vue';
  const SIZE = 10
  export default {
    components: {
      sPopup
    },
    onShareAppMessage() {
      return {
        from: 'menu'
      }
    },
    data() {
      return {
        defaltImage: '../../static/images/goods/icon_default_image.png',
        saleList: [], // 详情数据接口
        goodsList: [{
            id: 1,
            name: "添加商品",
            img: "../../static/images/home/icon_home_down_add_goods.png",
            url: "/pages/goods-add/goods-add"
          },
          {
            id: 2,
            name: "在售商品",
            img: "../../static/images/home/icon_home_down_goods_list.png"
          },
          {
            id: 3,
            name: "售罄商品",
            img: "../../static/images/home/icon_home_down_sold_out.png"
          },
          {
            id: 4,
            name: "商品回收站",
            img: "../../static/images/home/icon_home_down_recycle.png"
          },
          {
            id: 5,
            name: "商品分类",
            img: "../../static/images/home/icon_home_down_goods_category.png"
          },

        ],
        // 在售列表按钮
        sale_items: [{
            title: "改价",
            off_id: 1,
            offShow: false
          },
          {
            title: "下架",
            mind_id: 1,
            offShow: false
          },
          {
            title: "智能权重",
            del_id: 1,
            delShow: false
          },
          {
            title: "更多",
            del_id: 1,
            delShow: false
          },
        ],
        // 下架
        under_items: [{
            title: "上架",
            mind_id: 1,
            offShow: false
          },
          {
            title: "智能权重",
            del_id: 1,
            delShow: false
          },
          {
            title: "删除",
            del_id: 1,
            delShow: false
          },
        ],
        store_items: [{
            title: "改库存"
          },
          {
            title: "智能权重"
          },
          {
            title: "删除"
          },
        ],

        moreIndex: 0, // 更多标识
        newArr: {},
        newLst: [],
        goods_price: null,

        saleList: [], // 在售列表
        underList: [], // 下架
        items: {
          img: {}
        }, // 当前数据列表
        changePrice: "", // 改价调整价格
        mouseShow: false, // 改价
        store_Show: false, // 改库存
        modify_stock: "", // 修改库存
        firstFocus: false,
        downShow: false, // 下架
        weightShow: false, // 智能权重
        weightList: "", // 智能权重列表
        interfere: "", // 人工干预值
        moreShow: false, // 更多
        recycleShow: false, // 商品移至回收站
        shareShow: false, // 分享
        is_newShow: false, // 新品
        is_hotShow: false, // 热销
        is_bestShow: false, // 精品
        goods_id: "",
        getupShow: false, // 上架
        delShow: false, // 删除
        pagination: "", // 分页条数 信息

        more: 1, // 第几页
        count: 10, // 条数
        total: 0, // 总条数
        User: "", // 用户信息
        Height: 0, // 高

        scrollHeight: 0, // 自适应高度
        u_loadmore: true, // 加载中

        triggered: false, // 下拉刷新
        scrollTop: 0,
        old: {
          scrollTop: 0
        }
      }
    },
    onLoad() {
      this.$H.post("admin/merchant/goods/list", {
        pagination: {
          count: this.count,
          page: this.more
        }
      }).then(res => {
        if (res.status.succeed == 1) {
          this.total = res.paginated.total
          this.saleList = res.data
          this.pagination = res.paginated
          this.u_loadmore = false
        }
      })
      this.$H.post("admin/user/userinfo").then(res => {
        this.User = res.data
      })
      // 下拉刷新
      this._freshing = false;
    },

    onShow() {
      if (getApp().globalData.price !== null) {
        var globalData = getApp().globalData.price;
        this.goods_price = globalData
      }
      // 更新一下列表
      this.$H.post("admin/merchant/goods/list", {
        pagination: {
          count: this.count,
          page: this.more
        }
      }).then(res => {
        this.saleList = res.data
      })
    },
    methods: {
      // 下拉刷新 自定义下拉刷新控件被下拉
      onPulling(e) {
        console.log("onpulling", e);
        this.triggered = true;
      },
      // 自定义下拉刷新被触发
      onRefresh() {
        if (this._freshing) return;
        this._freshing = true;
        setTimeout(() => {
          this.$H.post("admin/merchant/goods/list", {
            pagination: {
              count: this.count,
              page: this.more
            }
          }).then(res => {
            this.saleList = res.data
          })
          this.triggered = false;
          this._freshing = false;
        }, 1000)
      },
      // 自定义下拉刷新被复位
      onRestore() {
        this.triggered = 'restore'; // 需要重置
        console.log("onRestore");
      },
      // 加载数据
      getData() {
        this.$H.post("admin/merchant/goods/list", {
          pagination: {
            count: this.count,
            page: this.more
          }
        }).then(res => {
          this.saleList = res.data
          console.log(res)
        })
      },
      // 上拉加载函数
      scrolltolower(e) {
        let that = this
        // 每次上拉加载的数据比上一次多十个
        that.count += SIZE
        if (that.saleList.length == that.total) {
          return
        } else {
          setTimeout(() => {
            that.getData()
          }, 1000)
        }
      },
      // 滚动时触发
      scroll(e) {
        this.old.scrollTop = e.detail.scrollTop
      },
      // 回到顶部
      loadmores() {
        this.scrollTop = this.old.scrollTop
        this.$nextTick(function() {
          this.scrollTop = 0
        });
      },

      // 商品详情
      goodsDetail(item) {
        uni.navigateTo({
          url: "/pages/goods-edit/goods-edit?goods_id=" + item.goods_id
        })
      },
      // 更新列表
      updataList() {
        this.$H.post("admin/merchant/goods/list").then(res => {
          this.saleList = res.data
        })
      },
      // 商品分类列表
      tabgoods(i) {
        if (i == 1) {
          uni.navigateTo({
            url: "/pages/goods-add/goods-add"
          })
        } else if (i == 2) {
          uni.navigateTo({
            url: "/pages/goods-sale/goods-sale"
          })
        } else if (i == 3) {
          uni.navigateTo({
            url: "/pages/goods-sell/goods-sell"
          })
        } else if (i == 4) {
          uni.navigateTo({
            url: "/pages/goods-recycle/goods-recycle"
          })
        } else if (i == 5) {
          if (this.User.is_merchant) {
            uni.navigateTo({
              url: "/pages/goods-class/goods-class"
            })
          } else {
            uni.navigateTo({
              url: "/pages/goods-class-terrace/goods-class-terrace"
            })
          }
        }
      },
      // 操作按钮
      goodsOpen(goodsItem, item) {
        this.items = item
        if (goodsItem.title == '改价') {
          this.mouseShow = true
        } else if (goodsItem.title == '下架') {
          this.downShow = true
        } else if (goodsItem.title == '智能权重') {
          this.$H.post("admin/merchant/goods/intelligentWeight", {
            goods_id: item.goods_id
          }).then(res => {
            this.weightList = res.data
            console.log(res.data)
          })
          this.weightShow = true
        } else if (goodsItem.title == '更多') {
          this.moreShow = true
        }
      },
      // 调整价钱输入框
      changeInput(e) {
        this.changePrice = e.detail.value
        console.log(e)
      },
      // 确认修改
      ConfirmPrice() {
        this.$H.post("admin/merchant/goods/price/updateShopPrice", {
          goods_id: this.items.goods_id,
          price: this.changePrice
        }).then(res => {
          console.log(res)
          this.mouseShow = false

        })
        this.updataList()
      },
      // 改价 弹框聚焦
      change_input(e) {
        console.log(e)
        this.firstFocus = true
        uni.pageScrollTo({
          scrollTop: 0,
          duration: 0
        });
      },
      // 关闭弹框
      close_focus() {
        this.firstFocus = false
      },
      open_focus() {
        this.change_input()
      },
      // 高级改价
      expert() {
        uni.navigateTo({
          url: "/pages/goods-edit-expert/goods-edit-expert?goods_id=" + this.items.goods_id
        })
      },
      // 下架
      downFarme() {
        this.$H.post("admin/goods/toggle/sale", {
          id: this.items.goods_id,
          type: 'offline'
        }).then(res => {
          console.log(res)
        })
        this.updataList()
      },
      // 智能权重 人工干预值
      weight() {
        this.$H.post("admin/merchant/goods/sort/update", {
          goods_id: this.items.goods_id,
          sort_order: this.interfere
        }).then(res => {
          console.log(res)
        })
        this.updataList()
      },
      // 监听人工干预值框
      interfereInput(e) {
        this.interfere = e.detail.value
      },
      // 商品移至回收站
      goods_recycle() {
        this.delShow = true
        this.moreShow = false
      },
      // 确认移至回收站
      confirm_delShow() {
        this.$H.post("admin/goods/trash", {
          id: this.items.goods_id
        }).then(res => {
          this.updataList()
        })
      },
      // 分享
      share() {
        this.shareShow = true
        this.moreShow = false
      },
      // 关闭更多
      cancelMore() {
        this.moreShow = false
      },
      // 取消分享
      cancelShare() {
        this.shareShow = false
      },
      // 设置 新品
      is_new() {
        this.is_newShow = true
        this.moreShow = false
      },
      confirm_is_new() {
        if (this.items.is_new == 0) {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'new',
            is_suggest: 1
          }).then(res => {
            console.log(res)
          })
        } else {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'new',
            is_suggest: 0
          }).then(res => {
            console.log(res)
          })
        }
        this.updataList()
      },
      // 设置热销 
      is_hot() {
        this.is_hotShow = true
        this.moreShow = false
      },
      confirm_is_hotShow() {
        if (this.items.is_hot == 0) {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'hot',
            is_suggest: 1
          }).then(res => {
            console.log(res)
          })
        } else {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'hot',
            is_suggest: 0
          }).then(res => {
            console.log(res)
          })
        }
        this.updataList()
      },
      // 设置精品
      is_best() {
        this.is_bestShow = true
        this.moreShow = false
      },
      confirm_is_bestShow() {
        if (this.items.is_best == 0) {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'best',
            is_suggest: 1
          }).then(res => {
            console.log(res)
          })
        } else {
          this.$H.post("admin/goods/toggle/suggest", {
            id: this.items.goods_id,
            type: 'best',
            is_suggest: 0
          }).then(res => {
            console.log(res)
          })
        }
        this.updataList()
      },
      // 上架商品
      goods_under(underItem, under) {
        this.items = under
        if (underItem.title == "上架") {
          this.getupShow = true
        } else if (underItem.title == "智能权重") {
          this.$H.post("admin/merchant/goods/intelligentWeight", {
            goods_id: under.goods_id
          }).then(res => {
            console.log(res)
            this.weightList = res.data
          })
          this.weightShow = true
        } else if (underItem.title == "删除") {
          this.delShow = true
        }
      },

      // 确认上架
      getupFarme() {

        this.$H.post("admin/goods/toggle/sale", {
          id: this.items.goods_id,
          type: 'online'
        }).then(res => {
          console.log(res)
        })
        this.updataList()
      },
      // 售罄商品 
      goods_store(storeItem, item) {
        this.goods_id = item.goods_id
        if (storeItem.title == "改库存") {
          this.store_Show = true
        } else if (storeItem.title == "智能权重") {
          this.$H.post("admin/merchant/goods/intelligentWeight", {
            goods_id: under.goods_id
          }).then(res => {
            console.log(res)
            this.weightList = res.data
          })
          this.weightShow = true
        } else if (storeItem.title == "删除") {
          this.delShow = true
        }
      },
      // 修改库存
      stock() {
        this.$H.post("admin/merchant/goods/stock/update", {
          goods_id: this.goods_id,
          number: this.modify_stock
        }).then(res => {
          this.store_Show = false
          this.$H.post("admin/merchant/goods/list").then(res => {
            this.saleList = res.data
            console.log(res)
          })
        })
      },
      // 监听input框
      modify(e) {
        this.modify_stock = e.detail.value
      },
      // 改价 弹框聚焦
      store_input(e) {
        console.log(e)
        this.firstFocus = true
      },
      // 关闭弹框
      close_store() {
        this.firstFocus = false
      },
      open_store() {
        this.change_input()
      },

    },
    onPullDownRefresh() {
      // 监听下拉刷新动作执行方法，每次手动下拉刷新都会执行一次
      console.log('refresh');
      setTimeout(() => {
        uni.stopPullDownRefresh(); // 停止下拉刷新动画
      }, 1000)
    },
    onReady() {
      let _this = this
      uni.getSystemInfo({
        success(resu) {
          const query = uni.createSelectorQuery()
          query.select('.scroll_header').boundingClientRect()
          query.exec(function(res) {
            _this.scrollHeight = resu.windowHeight - res[0].bottom + 'px';
          })
        }
      })
    },
  }
</script>

<style>
  .goods_icon {
    width: 30upx;
    height: 30upx;
  }

  .goods_im {
    width: 130upx;
    height: 100upx;
    border-radius: 50%;
  }

  .goods_card_head_left {
    width: 200upx;
    height: 200upx;
  }

  .goods_card_head_left .img_url {
    width: 200upx;
    height: 200upx;
    border-radius: 20upx;
  }

  .goods_card_head_right image {
    width: 30upx;
    height: 30upx;
  }

  .goods_card_content_footer view {
    border: 1px solid #808080;
    padding: 8upx 30upx;
    margin-right: 10upx;
    border-radius: 30upx;
  }

  .popupImg {
    width: 170upx;
    height: 170upx;
  }

  .deep /deep/ button {
    width: 70%;
    border-radius: 50upx;
    font-size: 30upx;
    background: linear-gradient(to right, #F31E3E, #FB4F37);
  }


  .s-popup-mask {
    background: rgba(204, 204, 204, 0.3) !important;
  }

  .content {
    background-color: rgb(237, 237, 237) !important;
    color: #666666;
  }

  .s-popup-wrap {
    background: rgba(204, 204, 204, 0) !important;
  }

  .icon_share view {
    color: #888;
  }

  .icon_share image {
    width: 120upx;
    height: 120upx;
  }

  .active_today {
    color: #ff0000;
    border-bottom: 5rpx solid #ff0000;
  }

  .user_img {
    width: 50upx;
    height: 50upx;
    background-color: #ffd1d0;
  }

  .today_title {
    background-color: #f6efef;
  }

  .today_hot {
    width: 150upx;
    height: 150upx;
  }

  .nowrap {
    white-space: nowrap;
  }
</style>
